package com.hbnu.test;

import com.hbnu.pojo.TUser;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

public class MyRowMapper implements RowMapper<TUser> {

    @Override
    public TUser mapRow(ResultSet resultSet, int i) throws SQLException {
        TUser tUser = new TUser();

//        获取数据
        int id = resultSet.getInt("id");
        String name = resultSet.getString("name");
        String password = resultSet.getString("password");
        String addr = resultSet.getString("addr");
        double salary = resultSet.getDouble("salary");

        tUser.setId(id);
        tUser.setName(name);
        tUser.setPassword(password);
        tUser.setAddr(addr);
        tUser.setSalary(salary);

        return tUser;
    }
}
